package org.hegang.design.first.builderpattern;

import java.util.ArrayList;
import java.util.List;

/**
 * @ClassName Meal
 * @Describe: TODO
 * @Author: gang.he
 * @Email: SmileSkylife@outlook.com
 * @Date: Created in 22:43 2019/7/1
 * @Modified_By: TODO
 * @Version: V1.0
 */
public class Meal {
    private List<Item> items = new ArrayList<>();

    public void addItem(Item item){
        items.add(item);
    }

    public float getCost(){
        float cost = 0.0f;
        for (Item item:items) {
            cost += item.price();
        }
        return cost;
    }

    public void showItems(){
        for (Item item:items) {
            System.out.print("Item :" + item.name());
            System.out.print(",Packing :" + item.packing().pack());
            System.out.println(",Price :" + item.price());
        }
    }
}
